package com.store.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.store.app.R;

import java.util.List;

/**
 * Created by lushan
 * on 2016/4/14 16:29 .
 */
public class ConStoDtea_Goods_TypeAdapter extends BaseAdapter{

    private Context mContext;
    private List<String> list;
    private int check_no=0;
    public ConStoDtea_Goods_TypeAdapter(Context c, List<String> beanlist) {
        this.mContext = c;
        this.list = beanlist;
    }
    public void setCheck_no(int check_no){
        this.check_no=check_no;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        Holder holder = null;
        if (view == null) {
            holder = new Holder();
            view = LayoutInflater.from(mContext).inflate(R.layout.item_constoredeta_goods_type, null);
            holder.title = (TextView) view.findViewById(R.id.tv_constoredata_goods_type);
            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }
        holder.title.setText(list.get(position));
        if(position==check_no){
            holder.title.setBackgroundResource(R.drawable.border_red_goods_type);
            holder.title.setTextColor(mContext.getResources().getColor(R.color.home_top_color));
        }else{
            holder.title.setBackgroundResource(R.color.transparent);
            holder.title.setTextColor(mContext.getResources().getColor(R.color.text_color_weak));
        }
        return view;
    }

    class Holder {
        TextView title;
    }

}
